home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 January / Game.EXE_01_2001.iso / demos / Blade of Darkness / data1.cab / Program_Executable_Files / Scripts / Demo_Stuff.py < prev    next >
Encoding:
Text File  |  2000-11-16  |  7.5 KB  |  313 lines

  1. ####################################################################################
  2. #
  3. #
  4. #
  5. #                dd ee mm oo !! !! !! !!
  6. #
  7. #
  8. #
  9. ####################################################################################
  10.  
  11. import Bladex
  12. import Reference
  13. import Menu
  14.  
  15. import Raster
  16.  
  17. import BUIx
  18. import BBLib
  19. import BInput
  20.  
  21. import darfuncs
  22. import GameText
  23. import TutorialScorer
  24.  
  25. fading_start_time=0
  26. logo_rebel = 0
  27. logo_codemasters=0
  28. logo_blade=0
  29.  
  30.  
  31. last_demo_msg_time=0
  32.  
  33. demo_is_active=0
  34. prev_was_menu=0
  35.  
  36.  
  37.  
  38. LOGOS_FULL=1
  39.  
  40. TutorialScorer.ActivateTutorialScorer("../../Data/Letras menu med.bmp")
  41. TutorialScorer.wMultiText.SetColor(255,0,0)
  42.  
  43. LastMessage = 0
  44.  
  45.  
  46. OnEnterDemo=0
  47. OnExitDemo=0
  48.  
  49. def StaticLogoRebel(time):
  50.     global last_demo_msg_time
  51.     global logo_rebel
  52.     global logo_codemasters
  53.     global logo_blade
  54.     global fading_start_time
  55.     global LastMessage
  56.  
  57.     alpha= (time-fading_start_time)*0.25
  58.     if alpha>0.8:
  59.         alpha=0.8
  60.     if alpha<0:
  61.         alpha=0
  62.  
  63.     if time-last_demo_msg_time>3.0:
  64.         GameText.WriteTextAux("DEMO mode - press any key",2.0,255,255,255,[])
  65.         last_demo_msg_time=time
  66.  
  67.     w, h = Raster.GetSize()
  68.  
  69.     Raster.SetPosition(w-136,h-90-10)
  70.     Raster.SetAlpha(alpha)
  71.     Raster.DrawBitmap(logo_rebel,128,90)
  72.  
  73.     Raster.SetPosition(0,h-110)
  74.     Raster.SetAlpha(alpha)
  75.     Raster.DrawBitmap(logo_codemasters,128,128)
  76.     
  77.     Raster.SetPosition(w/2.0-128,-90)
  78.     Raster.SetAlpha(alpha)
  79.     Raster.DrawBitmap(logo_blade,256,256)
  80.  
  81.  
  82.  
  83. def FadeLogoCodemasters(time):
  84.     global logo_codemasters
  85.     global fading_start_time
  86.     if (time-fading_start_time<2):
  87.         alpha= (time-fading_start_time)*0.5
  88.     else:
  89.         alpha= 1.0-(time-fading_start_time-2)*0.5
  90.  
  91.  
  92.     if alpha>1:
  93.         alpha=1
  94.     elif alpha<=0:
  95.         alpha=0
  96.         if (time-fading_start_time>1):
  97.             Bladex.RemoveAfterFrameFunc("FadeLogoCodemasters")
  98.             fading_start_time=Bladex.GetTime()+0.5
  99.             Bladex.SetAfterFrameFunc("StaticLogoRebel", StaticLogoRebel)
  100.  
  101.     Raster.SetPenColor(255,255,255)
  102.     Raster.SetAlpha(alpha)
  103.     if LOGOS_FULL==1:
  104.         Raster.SetPosition(0,0)
  105.         Raster.DrawBitmap(logo_codemasters,Raster.GetSize()[0],Raster.GetSize()[1])
  106.     else:
  107.         Raster.SetPosition(Raster.GetSize()[0]-256,Raster.GetSize()[1]-225)
  108.         Raster.DrawBitmap(logo_codemasters,255,255)
  109.  
  110.  
  111.  
  112. def FadeLogoRebel(time):
  113.     global logo_rebel
  114.     global fading_start_time
  115.  
  116.     if (time-fading_start_time<2):
  117.         alpha= (time-fading_start_time)*0.5
  118.     else:
  119.         alpha= 1.0-(time-fading_start_time-2)*0.5
  120.  
  121.     if alpha>1:
  122.         alpha=1
  123.     elif alpha<=0:
  124.         alpha=0
  125.         if (time-fading_start_time>1):
  126.             Bladex.RemoveAfterFrameFunc("FadeLogoRebel")
  127.             fading_start_time=Bladex.GetTime()+0.5
  128.             Bladex.SetAfterFrameFunc("FadeLogoCodemasters", FadeLogoCodemasters)
  129.  
  130.     Raster.SetPenColor(255,255,255)
  131.     Raster.SetAlpha(alpha)
  132.  
  133.     if LOGOS_FULL==1:
  134.         Raster.SetPosition(0,0)
  135.         Raster.DrawBitmap(logo_rebel,Raster.GetSize()[0],Raster.GetSize()[1])
  136.     else:
  137.         Raster.SetPosition(Raster.GetSize()[0]-256,Raster.GetSize()[1]-256)
  138.         Raster.DrawBitmap(logo_rebel,255,255)
  139.  
  140.  
  141.  
  142. def LaunchDemoCamera2(a,b):
  143.     global fading_start_time
  144.     global LastMessage
  145.  
  146.     fading_start_time=Bladex.GetTime()+1
  147.     Bladex.RemoveAfterFrameFunc("StaticLogoRebel")
  148.     Bladex.SetAfterFrameFunc("FadeLogoRebel", FadeLogoRebel)
  149.     darfuncs.LaunchMaxCamera("demo_travelling.cam",0,-1,LaunchDemoCamera)
  150.  
  151.  
  152. def LaunchDemoCamera(a,b):
  153.  
  154.     darfuncs.LaunchMaxCamera("demo_travelling.cam",0,-1,LaunchDemoCamera2)
  155.  
  156.  
  157. import pdb
  158. def FinishDemoFunc(x,y,z):
  159.     global Listener
  160.  
  161.     print "Demo_Stuff.FinishDemoFunc called"
  162.     
  163.     BInput.GetInputManager().GetAttachedDevice("Keyboard").RemoveListener("EndDemo")
  164.     Listener = None
  165.     DemoLoop()
  166.  
  167.  
  168. def DemoLoop():
  169.     global fading_start_time
  170.     global demo_is_active
  171.     global prev_was_menu
  172.     global Listener
  173.     global LastMessage
  174.  
  175.     global CurrentPerson
  176.     global FinishPerson
  177.  
  178.     AppMode=Bladex.GetAppMode()
  179.     import Scorer
  180.  
  181.     if AppMode=="Menu":
  182.         demo_is_active=1
  183.         prev_was_menu=1
  184.         print "DemoLoop-Menu2Demo"
  185.         Menu.ActivateMenu()
  186.         print "DemoLoop , activatemenu en menu2demo"
  187.         Bladex.SetAppMode("Demo")
  188.  
  189.         if OnEnterDemo:
  190.             OnEnterDemo()
  191.  
  192.         print "demo mode set up"
  193.  
  194.         Bladex.ExeMusicEvent( Bladex.GetMusicEvent("musica_loop_demo") )
  195.         fading_start_time=Bladex.GetTime()+1
  196.         Bladex.SetAfterFrameFunc("FadeLogoRebel", FadeLogoRebel)
  197.  
  198.         Listener=BInput.B_InputListener("EndDemo")
  199.         Listener.SetPythonFunc(FinishDemoFunc)
  200.         BInput.GetInputManager().GetAttachedDevice("Keyboard").AddListener(Listener)
  201.  
  202.         Bladex.AddScheduledFunc(Bladex.GetTime()+0.1, LaunchDemoCamera,(0,0))
  203.         Scorer.SetVisible(0)
  204.  
  205.     elif AppMode=="Demo":
  206.         demo_is_active=0
  207.         Bladex.ActivateInput() #la funcion launchMaxcamera la habia desactivado!
  208.         print "DemoLoop-Demo2Menu"
  209.         if prev_was_menu==1:
  210.             Menu.ActivateMenu()
  211.             print "set menu mode"
  212.             Bladex.SetAppMode("Menu")
  213.         else:
  214.             print "NO set 2 menu mode"
  215.             Bladex.SetAppMode("Game")
  216.  
  217.         if OnExitDemo:
  218.             OnExitDemo()
  219.  
  220.         Bladex.ExeMusicEvent(-1)
  221.         Bladex.RemoveAfterFrameFunc("FadeLogoRebel")
  222.         Bladex.RemoveAfterFrameFunc("FadeLogoCodemasters")
  223.         Bladex.RemoveAfterFrameFunc("StaticLogoRebel")
  224.  
  225.         prev_was_menu=0
  226.  
  227.         cam=Bladex.GetEntity("Camera")
  228.  
  229.         if Bladex.GetCurrentMap()!="Casa":
  230.             cam.SetPersonView("Player1")
  231.             cam.Cut()
  232.             Bladex.SetListenerPosition(1)
  233.             Scorer.SetVisible(1)
  234.  
  235.     elif AppMode=="Game":
  236.         prev_was_menu=0
  237.         demo_is_active=1
  238.         print "DemoLoop-Game2Demo"        
  239.         Bladex.SetAppMode("Demo")        
  240.         print "demo mode set up"
  241.  
  242.         Bladex.ExeMusicEvent( Bladex.GetMusicEvent("musica_loop_demo") )
  243.         fading_start_time=Bladex.GetTime()+1
  244.         Bladex.SetAfterFrameFunc("FadeLogoRebel", FadeLogoRebel)
  245.  
  246.         if OnEnterDemo:
  247.             OnEnterDemo()
  248.  
  249.         Listener=BInput.B_InputListener("EndDemo")
  250.         Listener.SetPythonFunc(FinishDemoFunc)
  251.         BInput.GetInputManager().GetAttachedDevice("Keyboard").AddListener(Listener)
  252.  
  253.         LaunchDemoCamera(0,0)
  254.         Scorer.SetVisible(0)
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265. #
  266. # Init 
  267. #
  268. def Init():
  269.     global logo_rebel
  270.     global logo_codemasters
  271.     global logo_blade
  272.  
  273.     
  274.     #
  275.     # FUNC itself
  276.     #
  277.     if Reference.DEMO_MODE==1:
  278.         Bladex.SetMenuTgapFunc(DemoLoop)
  279.     else:
  280.         return
  281.  
  282.  
  283.  
  284.     #
  285.     # LOGO REBELACT
  286.     #
  287.     BBLib.ReadMMP("../../Data/logorebel.mmp")
  288.     logo_rebel=Raster.BmpHandle("LOGOREBELALFA")
  289.  
  290.  
  291.  
  292.     #
  293.     # LOGO CODEMASTERS
  294.     #
  295.     BBLib.ReadMMP("../../Data/logocodemasters.mmp")
  296.     logo_codemasters=Raster.BmpHandle("LOGOCODEMASTERSALFA")
  297.  
  298.  
  299.  
  300.     #
  301.     # LOGO BLADE
  302.     #
  303.     BBLib.ReadMMP("../../Data/logoblade256.mmp")
  304.     logo_blade=Raster.BmpHandle("LOGOBLADE")
  305.  
  306.  
  307.  
  308.     #
  309.     # MUSICAS
  310.     #
  311.     Bladex.AddMusicEventMP3  ( "musica_loop_demo",     "..\\..\\Sounds\\tema.mp3",          0.1, 1.0, 1.0, 11000,     0, -1 )
  312.     Bladex.AddMusicEventMP3  ( "emptyloquesea_demo",   "",                                  0.1, 0.1, 1.0, 11000,     0, 0 )
  313.